package com.ruoyi.truth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.truth.domain.ComUser;
import com.ruoyi.truth.service.IComUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ComuserController
 * 
 * @author ruoyi
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/truth/comhome")
public class ComUserController extends BaseController
{
    @Autowired
    private IComUserService comUserService;

    /**
     * 查询Comuser列表
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComUser comUser)
    {
        startPage();
        List<ComUser> list = comUserService.selectComUserList(comUser);
        return getDataTable(list);
    }

    /**
     * 导出Comuser列表
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:export')")
    @Log(title = "Comuser", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComUser comUser)
    {
        List<ComUser> list = comUserService.selectComUserList(comUser);
        ExcelUtil<ComUser> util = new ExcelUtil<ComUser>(ComUser.class);
        util.exportExcel(response, list, "Comuser数据");
    }

    /**
     * 获取Comuser详细信息
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:query')")
    @GetMapping(value = "/{comUserid}")
    public AjaxResult getInfo(@PathVariable("comUserid") Long comUserid)
    {
        return success(comUserService.selectComUserByComUserid(comUserid));
    }

    /**
     * 新增Comuser
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:add')")
    @Log(title = "Comuser", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComUser comUser)
    {
        return toAjax(comUserService.insertComUser(comUser));
    }

    /**
     * 修改Comuser
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:edit')")
    @Log(title = "Comuser", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComUser comUser)
    {
        return toAjax(comUserService.updateComUser(comUser));
    }

    /**
     * 删除Comuser
     */
    @PreAuthorize("@ss.hasPermi('truth:comhome:remove')")
    @Log(title = "Comuser", businessType = BusinessType.DELETE)
	@DeleteMapping("/{comUserids}")
    public AjaxResult remove(@PathVariable Long[] comUserids)
    {
        return toAjax(comUserService.deleteComUserByComUserids(comUserids));
    }
}
